package com.efeichong.project.controller;

import com.efeichong.common.domain.ResponseData;
import com.efeichong.project.domain.vo.SysMenuVo;
import com.efeichong.project.service.SysMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author
 * @date 2020/11/25
 * @description 权限
 */
@Api(tags = "权限接口", value = "权限接口")
@RestController
@RequestMapping("/sysMenu")
@RequiredArgsConstructor
public class SysMenuController {

    private final SysMenuService sysMenuService;

    @ApiOperation(value = "权限详细")
    @GetMapping(value = "/getInfo")
    public ResponseData<SysMenuVo> getInfo(@RequestParam("id") Long id) {
        return new ResponseData(sysMenuService.getInfo(id));
    }

    @ApiOperation(value = "权限列表查询")
    @GetMapping("/list")
    public ResponseData<SysMenuVo> list(SysMenuVo sysMenuVo) {
        return new ResponseData(sysMenuService.selectByList(sysMenuVo));
    }

    @ApiOperation(value = "权限新增")
    @PostMapping("insert")
    public ResponseData insert(@RequestBody SysMenuVo sysMenuVo) {
        sysMenuService.insertSysMenu(sysMenuVo);
        return new ResponseData();
    }

    @ApiOperation(value = "权限编辑")
    @PostMapping("update")
    public ResponseData update(@RequestBody SysMenuVo sysMenuVo) {
        sysMenuService.updateSysMenu(sysMenuVo);
        return new ResponseData();
    }

    @ApiOperation(value = "权限删除")
    @GetMapping("/deleteById")
    public ResponseData deleteSysMenuById(@RequestParam("id") Long id) {
        sysMenuService.deleteById(id);
        return new ResponseData();
    }

}
